<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head>
    <meta charset="UTF-8">
    <title>我的线下实践 - 企业培训平台</title>
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <style>
        .info-box {
            padding: 20px;
            background-color: #e9ecef;
            border-radius: 8px;
            text-align: center;
            margin-top: 20px;
            color: #495057;
        }

        .offline-practice-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            background-color: #fff;
            border-radius: 8px;
            overflow: hidden; /* Ensures rounded corners apply to content */
        }

        .offline-practice-table th,
        .offline-practice-table td {
            border: 1px solid #ddd;
            padding: 12px 15px;
            text-align: left;
        }

        .offline-practice-table th {
            background-color: #f2f2f2;
            font-weight: bold;
            color: #333;
        }

        .offline-practice-table tr:nth-child(even) {
            background-color: #f9f9f9;
        }

        .offline-practice-table tr:hover {
            background-color: #e9e9e9;
        }

        .offline-practice-table .actions-column button {
            margin-right: 5px;
        }

        .btn-cancel {
            background-color: #dc3545;
            color: white;
            padding: 8px 12px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        .btn-cancel:hover {
            background-color: #c82333;
        }
    </style>
</head>
<body>
<div th:replace="~{fragments/header :: common-header}"></div>

<div class="main-content">
    <div class="container">
        <h1 class="page-title">我的线下实践</h1>

        <div th:if="${successMessage}" class="alert alert-success">
            <p th:text="${successMessage}"></p>
        </div>
        <div th:if="${errorMessage}" class="alert alert-danger">
            <p th:text="${errorMessage}"></p>
        </div>

        <div th:if="${!#lists.isEmpty(offlinePractices)}">
            <table class="offline-practice-table">
                <thead>
                <tr>
                    <th>实践所属课程</th>
                    <th>实践地点</th>
                    <th>实践时间</th>
                    <th>报名时间</th>
                    <th>备注</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="practice : ${offlinePractices}">
                    <td th:text="${practice.courseName}"></td>
                    <td th:text="${practice.practiceLocation}"></td>
                    <td th:text="${#dates.format(practice.practiceTime, 'yyyy-MM-dd HH:mm')}"></td>
                    <td th:text="${#dates.format(practice.enrollmentTime, 'yyyy-MM-dd HH:mm')}"></td>
                    <td th:text="${practice.notes}"></td>
                    <td class="actions-column">
                        <form th:action="@{/offlinePractice/cancel/{id}(id=${practice.id})}" method="post" style="display: inline;">
                            <button type="submit" class="btn btn-cancel" onclick="return confirm('确定要取消报名这个线下实践吗？');">取消报名</button>
                        </form>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div th:unless="${!#lists.isEmpty(offlinePractices)}" class="info-box">
            <p>您目前没有已报名的线下实践活动。</p>
        </div>
    </div>
</div>
</body>
</html>